package interfaceCustomer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

///this gui is considering the case of customer has selected only
//                                  1 car to subscribe. how to handle if he chose more than 1 car?

public class MonthlySubscriptionPanel extends JPanel implements ActionListener {
	
	private JButton btnBackToMenu, btnChangeSubType, btnRegister;
	private  JLabel lblCusId, lblCusName,lblAssignTo, lblSubNum, lblUsrChoice1, lblUsrChoice2, lblValidSince, lblexpierd, lblToalAmount;
	private JTextField txtCusId, txtCusName, txtAssignTo, txtSubNum, txtUsrChoice1, txtUsrChoice2, txtValidSince, txtexpierd, txtToalAmount;
	private CustomerFrame cf;

	public MonthlySubscriptionPanel(CustomerFrame _cf ) {
		
		cf = _cf;
		this.setLayout(null);	
	//	this.this.setBackground(new Color(0,0,0));
		
		
		btnBackToMenu = new JButton("Back To Menu");
		btnBackToMenu.setBounds(10, 215, 115, 25);
		this.add(btnBackToMenu);
		btnBackToMenu.addActionListener(this);
		
		btnChangeSubType = new JButton("Change Menu Type");
		btnChangeSubType.setBounds(161, 215, 145, 25);
		this.add(btnChangeSubType);
		btnChangeSubType.addActionListener(this);
		
		btnRegister = new JButton("Register");
		btnRegister.setBounds(342, 215, 120, 25);
		this.add(btnRegister);
		btnRegister.addActionListener(this);
		
		lblCusId = new JLabel("Customer ID:");
		lblCusId.setBounds(10, 10, 75, 25);
		this.add(lblCusId);
		
		lblCusName = new JLabel("Customer Name:");
		lblCusName.setBounds(224, 10, 97, 25);
		this.add(lblCusName);
		
		lblAssignTo = new JLabel("Subscription Assigned To Car Number:");
		lblAssignTo.setBounds(10, 40, 225, 25);
		this.add(lblAssignTo);
		
		lblSubNum = new JLabel("Subscription Number:");
		lblSubNum.setBounds(307, 40, 125, 25);
		this.add(lblSubNum);
		
		
		lblUsrChoice1 = new JLabel("Enter Garage Name:");
		lblUsrChoice1.setBounds(10, 90, 115, 25);
		this.add(lblUsrChoice1); 
		
		lblUsrChoice2 = new JLabel("Enter Leaving Time:");
		lblUsrChoice2.setBounds(10, 115, 115, 25);
		this.add(lblUsrChoice2);  
		
		lblValidSince = new JLabel("Valid Since:");
		lblValidSince.setBounds(10, 65, 70, 25);
		this.add(lblValidSince); 
		
		lblToalAmount = new JLabel("Total Amount:");
		lblToalAmount.setBounds(10, 160, 80, 25);
		this.add(lblToalAmount); 
		
		lblexpierd = new JLabel("Expiration Date:");
		lblexpierd.setBounds(210, 66, 95, 25);
		this.add(lblexpierd); 
		
		txtSubNum = new JTextField();
		txtSubNum.setBounds(437, 43, 60, 20);
		this.add(txtSubNum);
		txtSubNum.setEditable(false);
		
		txtCusId = new JTextField();
		txtCusId.setBounds(90, 12, 120, 20);
		this.add(txtCusId);
		txtCusId.setEditable(false);
		
		txtToalAmount = new JTextField();
		txtToalAmount.setBounds(93, 162, 60, 20);
		this.add(txtToalAmount);
		txtToalAmount.setEditable(false);
		
		txtAssignTo = new JTextField();
		txtAssignTo.setBounds(237, 43, 60, 20);
		this.add(txtAssignTo);
		txtAssignTo.setEditable(false);
		
		txtCusName = new JTextField();
		txtCusName.setBounds(326, 12, 120, 20);
		this.add(txtCusName);
		txtCusName.setEditable(false);
		
		txtValidSince = new JTextField();
		txtValidSince.setBounds(85, 68, 108, 20);
		this.add(txtValidSince);
		Date today=new Date();
		txtValidSince.setText(today.getDate() + "/" + ((today.getMonth())+1) + "/" + (1900+today.getYear()) + "  " + today.getHours() + ":" + today.getMinutes());  
		txtValidSince.setEditable(false);
		
		txtUsrChoice1 = new JTextField();
		txtUsrChoice1.setBounds(130, 92, 30, 20);
		this.add(txtUsrChoice1); 
		
		txtUsrChoice2 = new JTextField();
		txtUsrChoice2.setBounds(130, 117, 60, 20);
		this.add(txtUsrChoice2);     
		
		txtexpierd = new JTextField();                   
		txtexpierd.setBounds(312, 68, 60, 20);
		this.add(txtexpierd);
		txtexpierd.setEditable(false);
		
		this.setVisible(true);

	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnChangeSubType) {
			cf.ChangePanel(3.121);
		}
		if(e.getSource() == btnBackToMenu) {
			cf.ChangePanel(0);
		}
	}
	
	
	
	public void notuse ()
	{
		lblUsrChoice2=null;

		
	}

}
